package com.yzh.homework;

import java.util.Arrays;

/**
 * @author 于振晗
 * @title: HomeWork05
 * @description: TODO 生成一百个随机数，放入数组，然后排序输出。
 * @date 2020年08月18日
 * @path com.yzh.homework
 */
public class HomeWork05 {
    public static void main(String[] args) {
        int [] arr = new int [100];
        for (int i = 0; i < 100; i++) {
            arr[i] = (int)(Math.random()*100+1);
        }

        System.out.println(Arrays.toString(arr));
        int indexMin = 0;
        for (int i = 0; i < arr.length-1; i++) {
            indexMin = i;
            for (int j = i+1; j < arr.length; j++) {
                if (arr[indexMin]>arr[j]) {
                    indexMin = j;
                }
                if (indexMin!=i) {
                    int t = arr[indexMin];
                    arr[indexMin] = arr[i];
                    arr[i] = t;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
